<%-- 
    Document   : viewAll
    Created on : 05.08.2014, 22:28:00
    Author     : Andrey
--%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<div class="col-md-9">
    <button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#myModal">Add new Grant
        Application Area
    </button>
    <c:if test="${not empty grantAreas}">


        <table class="table table-striped table-bordered table-hover">
            <thead>
            <tr>
                <td>Id</td>
                <td>Name</td>
                <td>Link</td>
                <td>Controls</td>
            </tr>
            </thead>
            <tbody>
            <c:forEach var="grantArea" items="${grantAreas}">
                <tr>
                    <td>${grantArea.grantAreaId}</td>
                    <td>${grantArea.name}</td>
                    <td>${grantArea.link}</td>
                    <td>
                        <a href="<c:url value="/admin/areas/edit/${grantArea.grantAreaId}" />">
                            <button type="button" class="btn btn-success btn-sm">Edit</button>
                        </a>
                        <a href="<c:url value="/admin/areas/remove/${grantArea.grantAreaId}" />">
                            <button type="button" class="btn btn-warning btn-sm">Delete</button>
                        </a>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </c:if>
</div>

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <form:form modelAttribute="newGrantArea" method='POST' class="form-horizontal">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title" id="myModalLabel">Creating new Grant Application Area</h4>
                </div>
                <div class="modal-body">

                    <div class="form-group">
                        <label for="name">Name: </label>
                        <form:input path="name" class="form-control" id="name"
                                    placeholder="Enter name of Grant Application Area"/>
                    </div>
                    <div class="form-group">
                        <label for="link">Link: </label>
                        <form:input path="link" class="form-control" id="link"
                                    placeholder="Enter link to Grant Application Area"/>
                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="submit" class="btn btn-primary">Save changes</button>
                </div>
            </div>
        </div>
    </form:form>
</div>